function tag(id, openTag, closeTag) {
var el=document.getElementById(id);
if (el.setSelectionRange) {
	// W3C
	el.value = el.value.substring(0,el.selectionStart) + openTag + el.value.substring(el.selectionStart,el.selectionEnd) + closeTag + el.value.substring(el.selectionEnd,el.value.length);
}
else if (document.selection && document.selection.createRange) {
	// MSIE
	el.focus();
	var range = document.selection.createRange();
	range.text = openTag + range.text + closeTag;
}
}
